package com.mofeng.myshop.domain.po;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.mofeng.myshop.domain.po.base.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

/**
 * <p>
 * 订单
 * </p>
 *
 * @author MoFeng
 * @since 2024-04-16
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("tb_order_from")
@Schema(name = "OrderFrom对象", description = "订单")
public class OrderFrom extends BaseEntity {

    @Schema(description = "订单状态 0 暂存购物车 1 交易失败 2 交易完成 3 等待发货 4等待签收")
    private String state;

    @Schema(description = "金额")
    private String money;

    @Schema(description = "数量")
    private Integer count = 1;

    @Schema(description = "质量")
    private Integer multiplier;

    @Schema(description = "等级")
    private Integer level;

    @Schema(description = "是否是蓝图 0 没有 1 有")
    private String isBluePic;

    @Schema(description = "收货地址")
    private Long addressId;

    @Schema(description = "其他信息")
    private String otherMsg;

    @Schema(description = "商品发货错误信息")
    @TableField("`error_msg`")
    private String errorMsg;

    @Schema(description = "商品id")
    private Long commodityId;

    @Schema(description = "虚拟删除状态， 0 存在  1删除")
    @TableField("`delete`")
    private String delete;

    @Schema(description = "付款用户ID")
    private Long buyUserId;

    @Schema(description = "收货 用户ID")
    private Long toUserId;


    @TableField(exist = false)
    private Commodity commodity;

    @TableField(exist = false)
    private Project project;

    @TableField(exist = false)
    private CommodityCategory commodityCategory;

    @TableField(exist = false)
    private AddressMap addressMap;

    @TableField(exist = false)
    private UserBase buyUser;

    @TableField(exist = false)
    private UserBase toUser;


    public void setMoneyDouble(double money) {
        this.money = String.format("%.3f", money);
    }
}
